package com.knowif.common.format;

import com.knowif.system.model.MessageEnum;
import com.knowif.system.model.RestBean;

public abstract class AbstractController {

    protected <T> RestBean<T> success(MessageEnum m, T data){
        return new RestBean<T>(m, data);
    }

    protected <T> RestBean<T> fail(MessageEnum m, T data){
        return new RestBean<T>(m, data);
    }

    protected <T> RestBean<T> success(int code, String msg, T data){
        return new RestBean<T>(code, msg, data);
    }

    protected RestBean<Object> doProcess(Action act){
        return success(MessageEnum.SUCCESS, act.doAction());
    }

    public interface Action{
        int doAction();
    }
}
